package com.chuan.icons;

import java.util.HashMap;

import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.widget.TabHost;

public class FriendsTab extends TabActivity {
	// TAB 页的MSG Handler，用于 TAB 页的 Activity 通信，实现的相当挫。
	static public HashMap<Integer, FriendActivity> mActivityDict = new HashMap<Integer, FriendActivity>();

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Intent it = getIntent();

		String user = it.getStringExtra(Constants.PARAMETER_USER);
		String site = it.getStringExtra(Constants.PARAMETER_SITE);

		if (user == null || site == null) {
			finish();
		}

		mActivityDict.clear();

		final TabHost tabHost = getTabHost();
		tabHost.clearAllTabs();
		Intent new_it = new Intent(this, FriendActivity.class);

		new_it.putExtra(Constants.PARAMETER_USER, user);
		new_it.putExtra(Constants.PARAMETER_SITE, site);
		new_it.putExtra(Constants.PARAMETER_TYPE, Constants.PAIRED_TYPE);
		tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator(
				getResources().getString(R.string.tab_paired)).setContent(
				new_it));

		new_it = new Intent(this, FriendActivity.class);
		new_it.putExtra(Constants.PARAMETER_USER, user);
		new_it.putExtra(Constants.PARAMETER_SITE, site);
		new_it.putExtra(Constants.PARAMETER_TYPE, Constants.GUESS_TYPE);
		tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator(
				getResources().getString(R.string.tab_guess))
				.setContent(new_it));

		new_it = new Intent(this, FriendActivity.class);
		new_it.putExtra(Constants.PARAMETER_USER, user);
		new_it.putExtra(Constants.PARAMETER_SITE, site);
		new_it.putExtra(Constants.PARAMETER_TYPE, Constants.UNKNOWN_TYPE);
		tabHost.addTab(tabHost.newTabSpec("tab3").setIndicator(
				getResources().getString(R.string.tab_unknown)).setContent(
				new_it));
	}

	@Override
	public void onConfigurationChanged(Configuration newConfig) {
		super.onConfigurationChanged(newConfig);
		if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
		} else if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT) {
		}
	}
}
